package com.googlecode.imanager.client.event;

import com.googlecode.imanager.client.Application;
import com.googlecode.imanager.client.Control;
import com.googlecode.imanager.client.Document;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class PhaseEvent extends Event {

    private EvaluationPhase eventType;
    
    public PhaseEvent(Document target, EvaluationPhase eventType) {
        super(target);
        setEventType(eventType);
    }

    @Override
    protected void setTarget(Control target) {
        if (!(target instanceof Document)){
            throw new IllegalArgumentException("target");
        }
        super.setTarget(target);
    }

    @Override
    public Document getTarget() {
        return (Document) super.getTarget();
    }

    public final Application getApplication() {
        return getTarget().getApplication();
    }
    
    protected void setEventType(EvaluationPhase eventType) {
        if (eventType == null){
            throw new IllegalArgumentException("eventType");
        }
        this.eventType = eventType;
    }

    @Override
    public EvaluationPhase getEventType() {
        return eventType;
    }

}
